/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ttt.nor2.db;

import com.ttt.nor2.util.ExceptionUtil;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Hashtable;
import org.apache.log4j.Logger;

/**
 *
 * @author anuphabm
 */
public class HtbSender {

    private Logger logger = Logger.getLogger(HtbSender.class);
    private Connection conn;

    public HtbSender(Connection conn) {
        this.conn = conn;
        logger.debug("Start class Load sender...");
    }

    public Hashtable loadSender() {
        Hashtable htb = new Hashtable();

        String sql = "select * from sender";
        try {
            PreparedStatement pstmt = conn.prepareStatement(sql);
            ResultSet rs = pstmt.executeQuery();

            while (rs.next()) {
                logger.debug("[" + rs.getString("sendid") + "][" + rs.getString("sendname") + "]");
                htb.put(rs.getString("sendid"), rs.getString("sendname"));
            }

        } catch (SQLException ex) {
            logger.error("Exception load sender error..." + ExceptionUtil.getStackTrace(ex));
        }


        return htb;
    }
}
